export interface IHttpCode {
    /**
     * 访问成功
     */
    SUCCESS: number;
    /**
     * 访问失败
     */
    ERROR: number;
    /**
     * 请登录后访问
     */
    LOGIN: number;
    /**
     * 登录过期，请重新登录
     */
    RELOGIN: number;
    /**
     * 您没有权限访问
     */
    NOAUTH: number;
}
/**
 * http 请求方式
 */
type ContentType = "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data";
export interface IContentType {
    /**
     * json 数据
     */
    json: ContentType;
    /**
     * 表单数据
     */
    form: ContentType;
    /**
     * data数据
     */
    data: ContentType;
}
/**
 * http请求Method
 */
type MethodType = "get" | "post" | "put" | "head" | "patch" | "delete" | "head" | "options";
// http请求类型
export interface IMethod {
    get: MethodType;
    delete: MethodType;
    post: MethodType;
    put: MethodType;
    patch: MethodType;
    head: MethodType;
    options: MethodType;
}
export const CONTENT_TYPE: IContentType = {
    json: "application/json",
    form: "application/x-www-form-urlencoded",
    data: "multipart/form-data"
};
export const METHOD: IMethod = {
    get: "get",
    delete: "delete",
    post: "post",
    put: "put",
    patch: "patch",
    head: "head",
    options: "options",
};

export const HTTP_CODE: IHttpCode = {
    SUCCESS: 200,  // 访问成功
    ERROR: 400,    // 访问失败
    LOGIN: 7001,   // 请登录后访问
    RELOGIN: 7002, // 登录过期，请重新登录
    NOAUTH: 7003  // 您没有权限访问
};
// 处理响应数据 参数
export interface IExecutor {
    /**
     * 成功回调
     */
    resolve?: (val: any) => void;
    /**
     * 失败 回调
     */
    reject?: (val: any) => void;
    /**
     * 是否显示toast
     */
    isToast?: boolean;
}

export const defaultExecutor: IExecutor = {
    resolve: (val) => '',
    reject: (val) => '',
    isToast: true
};

// http请求可选 参数
export interface IRequestOptions {
    params: any; // 参数
    method: MethodType;
    contentType: ContentType;
    isToast: boolean; // 是否显示toast
}

export const defaultRequestOptions: IRequestOptions = {
    /**
     * 参数
     */
    params: {},
    /**
     * 请求方式
     */
    method: "get",
    /**
     * 提交数据方式
     */
    contentType: CONTENT_TYPE.json,
    /**
     * 是否显示提示信息
     */
    isToast: true
};
